test(cfapi): check for spurious attribute changes.
authorCamila Ayres <hello@camilasan.com>
Tue, 8 Apr 2025 13:35:55 +0000 (15:35 +0200)
committerbackportbot[bot] <backportbot[bot]@users.noreply.github.com>
Tue, 15 Apr 2025 08:30:25 +0000 (08:30 +0000)
Signed-off-by: Camila Ayres <hello@camilasan.com>
test/testsynccfapi.cpp

index d1ef2994e2866b71310889c5ac4760970355a435..20f509cb64aa99aa1c737fcf5efced2a96568d1a 100644 (file)
@@ -1449,6 +1449,43 @@ private slots:
         QVERIFY(fakeFolder.syncOnce());
         QCOMPARE(fakeFolder.currentLocalState(), fakeFolder.currentRemoteState());
     }
+
+    void testDetectSpuriousNotification() {
+#if !defined Q_OS_WIN
+        QSKIP("not applicable");
+#endif
+        FakeFolder fakeFolder{FileInfo{}};
+        auto vfs = setupVfs(fakeFolder);
+
+        QVERIFY(fakeFolder.syncOnce());
+        QCOMPARE(fakeFolder.currentLocalState(), fakeFolder.currentRemoteState());
+
+        const QString odpFile("odp/presentation.odp");
+        const QString odtFile("odt/document.odt");
+        fakeFolder.localModifier().mkdir("odp");
+        fakeFolder.localModifier().insert(odpFile);
+        fakeFolder.localModifier().mkdir("odt");
+        fakeFolder.localModifier().insert(odtFile);
+
+        QVERIFY(fakeFolder.syncOnce());
+        QCOMPARE(fakeFolder.currentLocalState(), fakeFolder.currentRemoteState());
+        ItemCompletedSpy completeSpy(fakeFolder);
+
+        QFile odp(fakeFolder.localPath() + odpFile);
+        QVERIFY(odp.open(QIODevice::ReadWrite));
+        odp.write(odpFile.toLatin1(), qstrlen(odpFile.toLatin1()));
+        odp.close();
+        QVERIFY(fakeFolder.syncOnce());
+        QVERIFY(itemInstruction(completeSpy, odpFile, CSYNC_INSTRUCTION_SYNC));
+        QCOMPARE(*vfs->pinState(odpFile), PinState::Unspecified);
+
+        QFile odt(fakeFolder.localPath() + odtFile);
+        QVERIFY(odt.open(QIODevice::ReadWrite));
+        odt.close();
+        QVERIFY(fakeFolder.syncOnce());
+        QVERIFY(itemInstruction(completeSpy, odtFile, CSYNC_INSTRUCTION_UPDATE_METADATA));
+        QCOMPARE(*vfs->pinState(odtFile), PinState::Unspecified);
+    }
 };
 
 QTEST_GUILESS_MAIN(TestSyncCfApi)